#include <bits/stdc++.h>
#ifndef DEBUG
#define debug
#endif
using namespace std;
using i64 = int64_t;

template<typename T>
struct List {
  struct Node {
    T v;
    Node *prev, *next;
  };
  Node *head, *tail;
  List() {
    head = new Node{T(), nullptr, nullptr};
    tail = new Node{T(), nullptr, nullptr};
    head->next = tail;
    tail->prev = head;
  }
  void push_back(const T &v) {
    Node *p = tail->prev;
    Node *node = new Node{v, p, tail};
    p->next = node;
    tail->prev = node;
  }
  T pop_front() {
    Node *node = head->next;
    erase(node);
    return node->v;
  }
  void erase(Node *node) {
    Node* prev = node->prev;
    Node* next = node->next;
    prev->next = next;
    next->prev = prev;
  }
  void merge(List &other) {
    // 最后一个元素，指向第一个元素
    Node* last = tail->prev;
    Node* first = other.head->next;
    last->next = first;
    first->prev = last;
    tail = other.tail;
  }
  bool empty() {
    return head->next == tail;
  }
  void pick() { // List<pair<int, List<int>>>
    for (Node *cur = head->next; cur != tail; cur = cur->next) {
      cout << cur->v.second.pop_front() << ' ';
      if (cur->v.second.empty()) {
        erase(cur);
      }
    }
    cout << endl;
    for (Node *cur = head->next; cur != tail; cur = cur->next) {
      while (cur->next && cur->next != tail && cur->v.first == cur->next->v.first) {
        cur->v.second.merge(cur->next->v.second);
        erase(cur->next);
      }
    }
  }
};
void solve() {
  int n;
  cin >> n;
  List<pair<int, List<int>>> list;
  List<int> temp;
  int last_c = -1;
  for (int i = 1; i <= n; i ++) {
    int c;
    cin >> c;
    if (c != last_c) {
      if (last_c != -1) {
        list.push_back({last_c, temp});
        temp = List<int>();
      }
      last_c = c;
      temp.push_back(i);
    } else {
      temp.push_back(i);
    }
  }
  list.push_back({last_c, temp});
  while (!list.empty()) {
    // 1. pick first of all list
    // 2. judge and merge
    list.pick();
  }
}
int main() {
  cin.tie(0)->sync_with_stdio(0);
  int T = 1;
  // cin >> T;
  for (int cas = 1; cas <= T; cas ++) {
    solve();
  }
}